package com.knowledge.graph.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.knowledge.graph.model.entity.Course;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description: 对课程表进行操作
 * @author jiwenlong
 * @date 2023/11/8 17:40
 * @version 1.0
 */
@Mapper
public interface CourseMapper extends BaseMapper<Course> {

    @Insert("insert into course(course_name,course_image,course_description,course_address) values(#{courseName},#{courseImage},#{courseDescription},#{courseAddress})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    public int insert(Course course);

    @Select("select id from course where invitation_code = #{text}")
    Long selectByCode(String text);

    @Select("select * from course where course_name = #{course}")
    List<Course> selectCourseList(String course);

    @Select("select * from course where TIMESTAMPDIFF(MONTH,update_time,now()) < #{time}")
    List<Course> listByUpdateTime(Integer time);
}
